import math
from decimal import Decimal


def bccomp(left_operand, right_operand, scale=0):
    left_operand = round(Decimal(str(left_operand)), scale)
    right_operand = round(Decimal(str(right_operand)), scale)

    if left_operand == right_operand:
        return 0
    return 1 if left_operand > right_operand else -1


def bcadd(left_operand, right_operand, scale=0):
    return round(Decimal(str(left_operand)) + Decimal(str(right_operand)), scale)


def bcsub(left_operand, right_operand, scale=0):
    return round(Decimal(str(left_operand)) - Decimal(str(right_operand)), scale)


def bcmul(left_operand, right_operand, scale=0):
    return round(Decimal(str(left_operand)) * Decimal(str(right_operand)), scale)


def bcdiv(left_operand, right_operand, scale=0):
    return round(Decimal(str(left_operand)) / Decimal(str(right_operand)), scale)


def bcmod(left_operand, modulus):
    return Decimal(str(left_operand)) % Decimal(str(modulus))


def bcpow(left_operand, right_operand, scale=0):
    return round(Decimal(str(left_operand))**Decimal(str(right_operand)), scale)


def bcsqrt(operand, scale=0):
    return round(math.sqrt(Decimal(str(operand))), scale)

